#include "bilbao/util/Queue.h"

namespace bilbao
{
	namespace util
	{
		//--------------------------------------------------------------------------------
		template <class T> Queue<T>::Queue(void)
			: _objs(0), ini(0), fim(0)
		{
		}
		//--------------------------------------------------------------------------------]
		template <class T> Queue<T>::~Queue(void)
		{
		}
		//--------------------------------------------------------------------------------
		template <class T> void Queue<T>::pop(void)
		{
			_objs[ini++] = -1;
			ini %= BQUEUE_CAPACITY;
		}
		//--------------------------------------------------------------------------------
		template <class T> void Queue<T>::push( T e )
		{
			_objs[fim%BQUEUE_CAPACITY] = e;
			fim = (fim+1) % BQUEUE_CAPACITY;
		}
		//--------------------------------------------------------------------------------
		template <class T> bool Queue<T>::find( T e )
		{
			for (int i=0; i < BQUEUE_CAPACITY; i++)
			{
				if ( _objs[i] == e ) return true;
			}

			return false;
		}
		//--------------------------------------------------------------------------------
		template <class T> void Queue<T>::print(void)
		{
			for (int i=0; i < BQUEUE_CAPACITY; i++)
			{
				std::cout << "Queue[" << i << "]=" << _objs[i] << std::endl;
			}
		}
	//--------------------------------------------------------------------------------
	} //namespace utils
} //namespace bilbao
